package com.web.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.web.entity.UserAccount;

/**
 * @author FDjavaone
 */
public class UserAccountSqlProvider {

    public String insertSelective(UserAccount record) {
        BEGIN();
        INSERT_INTO("t_user_account");
        
        if (record.getuId() != null) {
            VALUES("u_id", "#{uId,jdbcType=BIGINT}");
        }
        
        if (record.getProfit() != null) {
            VALUES("profit", "#{profit,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(UserAccount record) {
        BEGIN();
        UPDATE("t_user_account");
        
        if (record.getuId() != null) {
            SET("u_id = #{uId,jdbcType=BIGINT}");
        }
        
        if (record.getProfit() != null) {
            SET("profit = #{profit,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}